#!/bin/busybox sh

HEADERUUID="1131c013-1a12-4d16-9353-e6c08af98f6a"

rescue_shell() {
	eend
	eerror "$*"
	exec sh
}

waitforhead() {
	while ! findfs UUID="1131c013-1a12-4d16-9353-e6c08af98f6a" > /dev/null; do
		:
	done
}

# hard-coded standard color codes (skip tput detection)
GOOD=$(printf '\033[32;01m')
WARN=$(printf '\033[33;01m')
BAD=$(printf '\033[31;01m')
NORMAL=$(printf '\033[0m')
LASTMSG=""

COL=170

# Display an informational message
einfo() {
    echo " ${GOOD}*${NORMAL} $*"
}

# Display a warning message
ewarn() {
    echo " ${WARN}*${NORMAL} $*"
}

# Display an erorr message, and return failure
eerror() {
	LASTMSG=" * $*"
    echo -n " ${BAD}*${NORMAL} $*"
    return 1
}

# Start an operation, displaying a message
ebegin() {
	LASTMSG=" * $* ... "
    echo -n " ${GOOD}*${NORMAL} $* ... "
}

# Display the status of the operation started with ebegin
eend() {
    if [ "${?:-0}" = "0" ]; then
		printf '%s%*s%s' "$GOOD" $(( $COL - ${#LASTMSG} )) "[ ok ]" "$NORMAL"
    else
		printf '%s%*s%s' "$BAD" $(( $COL - ${#LASTMSG} )) "[ !! ]" "$NORMAL"
    fi
}

